﻿using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Data;
namespace WPFExcelReport
{
    public partial class TGV04 : ViewBase
    {
        #region ==LIEFSCH===========
        public static readonly DependencyProperty LIEFSCHProperty = DependencyProperty.Register("LIEFSCH",
            typeof(string), typeof(TGV04),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnLIEFSCHChanged));
        public string LIEFSCH
        {
            get
            {
                return (string)GetValue(LIEFSCHProperty);
            }
            set
            {
                SetValue(LIEFSCHProperty, value);
            }
        }
        private static void OnLIEFSCHChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TGV04;
            if (src != null)
            {
                src.LIEFSCH = (string)e.NewValue;
                src.Clear();
            }
        }
        #endregion 
        
        public TGV04()
        {
            MV = new VGPACK();
            IsMasterFromMV = true;
            TBMain = MV.SetProd.Tables[TB]; 
            InitializeComponent();
        }
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return;
            base.Window_Loaded(sender, e);
        } 
        public void Clear()
        {
            if (TBMain == null)
                return;
            TBMain.Clear();
        }
        public void Load()
        {
            if (LIEFSCH == "")
                return;
            DataRow dwData = TBMain.NewRow();
            dwData["GPAMANDANT"] = app.Mandant;
            dwData["GPALIEFSCH"] = LIEFSCH;
            DataSet SResult = ((VGPACK)MV).QueryGPACK(dwData, 4);
            MergeData(SResult,true);
        } 

        private void Load_Click(object sender, RoutedEventArgs e)
        {
            Load();
        }
    }
}